﻿Chenxin.UI.PublicInfo=Chenxin.extend(Chenxin.UI.PageCommon,{
    autoInitForm:false,
    actionUrl:'/service/PublicInfo.ashx',
    createSearch:function(){
		return new Chenxin.UI.PublicInfoSearch({
			scope:this,
			afterGetParamJson:function(data){
			    data.op='search';
			    data.type=$("#ctl00_main_hidType").val();
            }
		});
	},
	createGrid: function() {
        return new Chenxin.UI.Pagination({
			actionUrl:this.actionUrl,
            id: 'allGrid',
            renderTo: 'public_table',
			data:{op:'search',type:$("#ctl00_main_hidType").val()},
			autoLoad:true
        });
    },
    initEvent: function() {
        var _this = this;
        
        //删除点击事件
        //$('#btn_del').click(function(){
            //_this.dellist();
	    //});
	    
	    //全选(反选)点击事件
	    $('#lblck').live('click',function(){
            $("input[name=ckpublic]").attr('checked',$(':checkbox',this).attr('checked'));
        });
        
        //详情点击事件
        $('#btndetail').live('click',function(){

	    });
	    
        //附件点击事件
        $('#btnattachment').live('click',function(){

        });
        
        //我的信息点击事件
        $('#btnMyself').click(function(){
            var param = _this.search.getParamJson();
            param.user = 'myself';
            param.type=$("#ctl00_main_hidType").val();
            //_this.grid.reload(param,true);
            _this.reloadGrid(param);
	    });
        
    },
    dellist: function() {
        var _this = this;
        var id = "";
        $(':checkbox:checked').each(function() {
            if (this.name == 'ckpublic') {
                if (id == '') {
                    id += this.value;
                } else {
                    id += "," + this.value;
                }
            }
        });
        if (!id) {
            alert('请选择至少一条记录！');
            return;
        }
        if (confirm('确定要删除选中记录吗？')) {
            Chenxin.ajax({
                type: "post",
                dataType: "json",
                url: this.actionUrl,
                data: { op: 'dellist', modelid: id},
                onSuccess: function(data, msg) {
                    alert(msg);
                    if (_this.grid) {
                        _this.grid.reload();
                    }
                    if (this.afterDelSucc) {
                        _this.afterDelSucc.call(_this, data, msg);
                    }
                }
            });
        }
    },
	initComponent:function(){
	    Chenxin.UI.PublicInfo.superclass.initComponent.call(this);
	    var title ="查看公告信息";
        switch($("#ctl00_main_hidType").val()){
            case "0":
                title = "查看公告信息";
                break;
            case "10":
                title = "查看通知信息";
                break;
            case "20":
                title = "查看一手房信息";
                break;
            case "30":
                title = "查看二手房信息";
                break;
            case "40":
                title = "查看其他信息";
                break;
            case "50":
                title = "查看特别信息";
                break;
            case "100":
                title = "IT部专栏";
                break;
            case "110":
                title = "权证专栏";
                break;
            case "120":
                title = "法务专栏";
                break;
            case "130":
                title = "行政人事专栏";
                break;
            case "140":
                title = "案例馆";
                break;
        }
        $("#atitle").text(title);
        $("#htitle").text(title);
        document.title=title;
	}
}); 

/**
*查询面板
*/
Chenxin.UI.PublicInfoSearch=Chenxin.extend(Chenxin.UI.SearchCommon,{
    id:'public_search',
	initEvent:function(){
		var _this=this; 
		
        //查询按钮
		$('#btnSreach').click(function(){
		    _this.scope.reloadGrid();
		});
	},
	createComboList:function(){
	    var _this = this;
	    
	    //五级联Combo
        var combl = new Chenxin.UI.StructComboList();
        var structs = combl.comboList;
        
	    //发布时间
		var publishtime = new Chenxin.UI.Combo({
			containerId: '#publishtime',
			tbxWidth:45,
			items:comboCommon.publishtimeType
		});
		
	    //弹出
		var ispopup = new Chenxin.UI.Combo({
		    containerId:'#ispopup',
		    tbxWidth:45,
		    items:comboCommon.ispopupType
		});
		structs.push(publishtime);
		structs.push(ispopup);
        return structs;

	},
    initComponent: function() {
        Chenxin.UI.PublicInfoSearch.superclass.initComponent.call(this);
        if($("#ctl00_main_hidType").val() != "50" )
        {
            $("#liispopupt").hide();
            $("#liispopup").hide();    
        }
        else
        {
            $("#liispopupt").show();
            $("#liispopup").show();  
        }
    }
});

$(document).ready(function() {    

    this.PublicInfo = new Chenxin.UI.PublicInfo();
});